package 算法.LeetCode91.每日打卡题目;

import 算法.NiuKe.ListNode;

/**
 * @author: 谢君臣
 * @create: 2021-02-14 14:15
 * @founction: XXXX
 */
public class day10 {
    public static void main(String[] args) {

    }
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        ListNode p = headA;
        while (p!=null){
            ListNode q = headB;
            while (q!=null){
                if (p==q)
                    return p;
                else
                    q= q.next;
            }
            p = p.next;
        }
        return null;
    }
    public ListNode getIntersectionNode1(ListNode headA, ListNode headB) {
        ListNode pA = headA, pB = headB;
        while(pA != pB){
            pA = pA == null? headB : pA.next;
            pB = pB == null? headA : pB.next;
        }
        return pA;
    }
}
